package com.aboverock.autoconfigure.properties;

import com.aboverock.common.constant.KbsmartConstant;
import com.aboverock.core.spring.SpringContextHolder;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;

;

/**
 * 数据湖配置属性.
 * 
 * @author Rock Wang
 *
 */
@ConfigurationProperties(prefix = "kbsmart.datalake")
public class DatalakeProperties {
    private static final Logger logger = LoggerFactory.getLogger(DatalakeProperties.class);
    /** The app id. */
    private String appId = "";

    /** The app secret. */
    private String appSecret = "";

    /** The token url. */
    private String tokenUrl = "";

    /** The base url. */
    private String baseUrl = "";
    
    /** The user id. */
    private String userId = "";

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public String getTokenUrl() {
        if (null != SpringContextHolder.getActiveProfile() && SpringContextHolder.getActiveProfile()
                .equals(KbsmartConstant.Profile.PRODUCTION)) {
            if (StringUtils.contains(tokenUrl, ".dev.") || StringUtils.contains(tokenUrl, ".qa.")) {
                logger.error("using test or dev datalake config in prod enviroment!");
            }
        }
        return tokenUrl;
    }

    public void setTokenUrl(String tokenUrl) {
        this.tokenUrl = tokenUrl;
    }

    public String getBaseUrl() {
        if (null != SpringContextHolder.getActiveProfile() && KbsmartConstant.Profile.PRODUCTION
                .equals(SpringContextHolder.getActiveProfile())) {
            if (StringUtils.contains(baseUrl, ".dev.") || StringUtils.contains(baseUrl, ".qa.")) {
                logger.error("using test or dev datalake config in prod enviroment!");
            }
        }
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

}
